package com.zee.wechat.framework.configuration;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author Zee
 * @since 2020年6月19日
 */
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
   /* @Bean
    public Docket job() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()).groupName("任务管理")
                .select()
                //为当前包路径
                .apis(RequestHandlerSelectors.basePackage("com.travelcloud.module.jobs"))
                .paths(PathSelectors.any())
                .build();
    }
    @Bean
    public Docket product() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()).groupName("产品管理")
                .select()
                //为当前包路径
                .apis(RequestHandlerSelectors.basePackage("com.travelcloud.module.product"))
                .paths(PathSelectors.any())
                .build();
    }*/

    @Bean
    public Docket back() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()).groupName("接口管理")
                .select()
                //为当前包路径
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                //页面标题
                .title("swaggerAPI接口")
                //版本号
                .version("2.0")
                //描述
                .description("API接口")
                .build();
    }

}
